package com.whale.controllers;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.whale.constants.MenuGroupConstants;

/**
 * Handles All request from Blinds application.
 */
@Controller
public class BlindsController extends AbstractController {

	private final static String TULLES = "/tulles";
	private final static String BLINDS_GROUP = "/blindsGroup";
	private final static String ACCESSORIES = "/accessories";
	private final static String FEEDBACKS = "/feedbacks";

	// home handlers

	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Model model) {
		populateNavigation(model, "/", MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/home";
	}

	// blinds group handlers

	@RequestMapping(value = BLINDS_GROUP, method = RequestMethod.GET)
	public String getListBlindsGroup(HttpServletRequest request, Model model) {
		populateNavigation(model, BLINDS_GROUP,
				MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/listBlindsGroup";
	}

	@RequestMapping(value = BLINDS_GROUP + "/{blindsGroupId}", method = RequestMethod.GET)
	public String getBlindsGroup(@PathVariable String blindsGroupId,
			HttpServletRequest request, Model model) {
		populateSubNavigation(model, BLINDS_GROUP, BLINDS_GROUP + "/"
				+ blindsGroupId, MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/blindsGroup";
	}

	// accessories handlers

	@RequestMapping(value = ACCESSORIES, method = RequestMethod.GET)
	public String getAccessories(HttpServletRequest request, Model model) {
		populateNavigation(model, ACCESSORIES,
				MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/accessories";
	}

	// tulles handlers

	@RequestMapping(value = TULLES, method = RequestMethod.GET)
	public String getTulles(HttpServletRequest request, Model model) {
		populateNavigation(model, TULLES, MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/tulles";
	}

	// feedback handlers

	@RequestMapping(value = FEEDBACKS, method = RequestMethod.GET)
	public String getFeedbacks(HttpServletRequest request, Model model) {
		populateNavigation(model, FEEDBACKS,
				MenuGroupConstants.USER_MENU_GROUP_ID);
		return "blinds/feedbacks";
	}
}
